# ref: 
# https://blog.csdn.net/HDFQQ188816190/article/details/98599940  adb 命令大全（简洁明了）adb命令启动应用
# https://blog.csdn.net/freedom_fd/article/details/94553284 python编写 钉钉自动 打卡脚本



import time
import os
import requests



def RemoteReporter(title,text):
    sckey = 'SCT44773TW2CNSLIgnbVtL1KaBIJOmbsi'#在发送消息页面可以找到
    url = 'https://sc.ftqq.com/%s.send?text=%s'%(sckey,title)
    #text为推送的title,desp为推送的描述
    url = 'https://sc.ftqq.com/%s.send?text=%s&desp=%s'%(sckey,title,text)
    requests.get(url)
    return

deviceId=' 7SK7N18915002863 '    # 这是韩国安妮的id

basicHead=' adb -s ' + deviceId + ' shell '

print(os.system(basicHead + 'input keyevent 224 ')) 
time.sleep(2)
print(os.system(basicHead + 'input tap 850 2033 ')) 
time.sleep(2)
# start dingding
# https://www.cnblogs.com/botoo/p/7903714.html
# 查询Activity
print(os.system(basicHead + 'am start -n com.alibaba.android.rimet/.biz.LaunchHomeActivity')) 
time.sleep(8)
print(os.system(basicHead + 'input tap 540 2050 ')) 
time.sleep(8)
print(os.system(basicHead + 'input tap 450 1000 ')) 
time.sleep(8)
print(os.system(basicHead + 'input tap 550 1300 ')) 
time.sleep(8)
# back to home
print(os.system(basicHead + 'input keyevent 3')) 
time.sleep(2)
# kill dingding
print(os.system(basicHead + 'am force-stop com.alibaba.android.rimet')) 
time.sleep(2)
print(os.system(basicHead + 'input keyevent 223 ')) 


RemoteReporter('已打卡','正文')
